import { getAttrs } from '@/services/goods';

const goodsModel = {
  namespace: 'goods',
  state: {
    attrs: [], // 规格列表
  },
  effects: {
    *fetchAttrs(_, { call, put }) {
      const response = yield call(getAttrs);
      yield put({
        type: 'show',
        payload: response.data || [],
      });
    },
  },
  reducers: {
    show(state, action) {
      return {
        ...state,
        attrs: action.payload || [],
      };
    },
  },
};

export default goodsModel;
